package com.tm.fiverole.security.domain;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * 新建一个Pojo类
 *
 * 用于身份认证与授权
 */
@Data
public class User implements UserDetails {

    private Long id;
    //用户名
    private String username;
    //用户密码
    private String password;
    //记住
    private Boolean rememberMe;
    //验证码 code码
    private String verifyCode;
    // 权限
    private String power;
    //有效期
    private Long expirationTime;
    //用户权限
    private List<SimpleGrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}